import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { Bars } from '@/components/charts/bars'; import { LineChart } from '@/components/charts/line-chart'; import { WorldMap } from '@/components/charts/world-map'; import { CompanyMiniList, CompanyTable } from '@/components/company/company-table'; import { EventList } from '@/components/events/event-row'; import { CountryChip } from '@/components/ui/badges'; import { Container, Empty, Note, PageHeader, Section, Stat, StatGrid } from '@/components/ui/section'; import { api, ApiError, safe } from '@/lib/api'; import { fmtInt, fmtPctSigned, fmtScore } from '@/lib/format'; import { routes } from '@/lib/site'; import type { CompanyCard, CountryDetailRaw } from '@/lib/types'; export const revalidate = 300; async function load(code: string): Promise { try { return await api.country(code.toUpperCase()); } catch (e) { if (e instanceof ApiError && e.notFound) notFound(); throw e; } } export async function generateMetadata({ params }: { params: Promise<{ code: string }> }): Promise { const { code } = await params; const d = await safe(api.country(code.toUpperCase())); if (!d) return { title: 'Country' }; return { title: `${d.name} — country atlas`, description: `${d.name}: ${Array.isArray(d.companies) ? d.companies.length : d.companies} monitored companies, ${d.events_30d} structured events in 30 days, hiring momentum ${fmtPctSigned(d.hiring_momentum_30d)}.`, alternates: { canonical: `/country/${code.toLowerCase()}` } }; } export default async function CountryPage({ params }: { params: Promise<{ code: string }> }) { const { code } = await params; const d = await load(code); const companies: CompanyCard[] = Array.isArray(d.companies) ? d.companies : []; const count = Array.isArray(d.companies) ? d.companies.length : d.companies; const map = await safe(api.map('events_30d')); const buckets = (map?.buckets ?? []).filter((b) => b.country.toUpperCase() === d.code.toUpperCase()); return ( Country atlas / {d.region && {d.region}} } title={d.name} lede={`${fmtInt(count)} monitored companies headquartered in ${d.name}. Activity and hiring are averages over the monitored population.`} />
{d.series?.length > 1 ? ({ day: p.day, value: p.value })) }]} height={200} yZero /> : }
{d.industry_mix?.length ? ({ key: m.industry, label: m.industry.replace(/-/g, ' '), value: m.companies, href: routes.industry(m.industry) }))} /> : }
{buckets.length ? : }
Country attribution uses the company’s headquarters. Expansion events (new offices, new countries) appear under the company’s home country and on the destination country’s timeline where detected.
); }